#ifndef _STAT_H_
#define _STAT_H_
#include <pthread.h>

#define MAX_STRING 1500
#define MAX_ENTRY 30

struct url_item
{
	char url[MAX_STRING];
	int success;
	int time;
	int size;
};
struct cache_stat
{
	pthread_mutex_t lock;
	unsigned int index;
	struct url_item item[MAX_ENTRY];
	unsigned int fail;
	unsigned int success;
	unsigned int hit_success;
	unsigned int hit_404;
	unsigned int remove_scrap;

	/* cleaner info */
	unsigned int check;
	unsigned int clean;
	char lastcheck[MAX_STRING];
	char lastclean[MAX_STRING];
};

#define stat_atom_inc(stat, var) do{\
	stat_lock(stat);\
	stat->var ++;\
	stat_unlock(stat);} while (0)

int stat_init(struct cache_stat *stat);

void stat_lock(struct cache_stat *stat);

void stat_unlock(struct cache_stat *stat);

#endif
